import lejos.nxt.LCD;
import lejos.nxt.UltrasonicSensor;
import lejos.robotics.subsumption.Behavior;


public class RightSonarBehaviour implements Behavior 
{


	//	private UltrasonicSensor leftSonar;
	private UltrasonicSensor rightSonar;
	private MapMaker mm = null;

	public RightSonarBehaviour(MapMaker mm)
	{
		this.mm = mm;
		this.rightSonar = mm.rightSonar;
		//		this.leftSonar = mm.leftSonar;    
	}
	@Override
	public boolean takeControl() 
	{ 		
		//		leftSonar.ping();
		rightSonar.ping(); 
		return rightSonar.getDistance() < 30; 	
	}

	@Override
	public void suppress() 
	{  
		mm.snav.stop();
	}

	@Override
	public void action() {

		mm.snav.rotate(10);  
		mm.snav.stop();
		mm.snav.forward();
		
		do	{ mm.UpdatePose(); }	while( mm.snav.isMoving() );
	}


}
